<?php
$this->load->view('header');
$week_arr = $this->config->item('week');
$subject_arr = $this->config->item('comm.subject');
$grade_arr = $this->config->item('comm.grade');
$time_arr = $this->config->item('comm.time');
?>
    <div class="page-container">
        <?php $this->load->view('sidebar');?>
        <!-- BEGIN CONTENT -->
        <div class="page-content-wrapper">
            <div class="page-content">
                <?php $this->load->view('sale/_sub_nav');?>
                <div class="row">
                    <div class="col-md-12">
                        <div class="table-toolbar">
                            <div class="pull-right">
                                <a href="<?php echo site_url('/teach/class_create');?>" class="btn blue" >
                                    <i class="fa fa-plus"></i> 新建课表
                                </a>
                                <button id="class_search_btn" class="btn yellow">
                                    <i class="fa fa-search"></i> 搜索
                                </button>
                            </div>
                        </div>
                        <table class="table table-bordered">
                            <thead>
                                <tr>
                                    <th>年级</th>
                                    <th>科目</th>
                                    <th>授课老师</th>
                                    <th>日期</th>
                                    <th>星期</th>
                                    <th>8:00-9:30</th>
                                    <th>9:30-11:00</th>
                                    <th>11:00-12:30</th>
                                    <th>14:30-16:00</th>
                                    <th>16:00-17:30</th>
                                    <th>19:00-20:30</th>
                                    <th>20:30-22:00</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php foreach($classes as $class):?>
                                        <tr>
                                            <td rowspan="<?php echo count($class->days);?>" style="vertical-align:middle;"><?php echo $grade_arr[$class->grade];?></td>
                                            <td rowspan="<?php echo count($class->days);?>" style="vertical-align:middle;"><?php echo $subject_arr[$class->subject];?></td>
                                            <td rowspan="<?php echo count($class->days);?>" style="vertical-align:middle;"><a href="teach/classes?teacher=<?php echo $class->teacher_id;?>"><?php echo $class->teacher_name;?></a></td>
                                            <?php foreach($class->dayss as $day):?>
                                                <?php echo var_dump($class->dayss);?>
                                                <?php if(is_object($day)):?>
                                                    <td><?php echo $day->date;?></td>
                                                <td><?php echo '星期'.$week_arr[date('w',strtotime($day['date']))];?></td>
                                                <?php foreach($day->students as $student):?>
                                                        <?php $time[$student->time] = '<td><a href="teach/classes?student='.$student->student_id.'">'.$student->student_name.'</a></td>';?>
                                                <?php endforeach;?>
                                                <?php endif;?>
                                                <?php for($i=0;$i<7;$i++):?>
                                                      <?php if(isset($time[$i])):?>
                                                            <?php echo $time[$i];?>
                                                        <?php else:?>
                                                            <?php echo '<td></td>';?>
                                                        <?php endif;?>
                                                <?php endfor;?>
                                            <?php endforeach;?>
                                        </tr>
                                <?php endforeach;?>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>    <!-- END CONTENT -->
    </div>




<?php $this->load->view('footer');?>

<script type="text/javascript" src="assets/scripts/custom/clue.js"></script>

<script>
    jQuery(document).ready(function() {
        App.init(); // initlayout and core plugins
        Clue.init();
    });
</script>

</body>
<!-- END BODY -->
</html>

